package app.server.project.main.service.dto.cms;

import app.server.project.core.constants.Def;
import app.server.project.core.util.MathUtil;
import app.server.project.main.service.bo.dbquery.CMSUserinfoBO;
import app.server.project.main.service.constants.LuckType;
import app.server.project.main.service.db.entity.cfg.RaceCfgEntity;
import app.server.project.main.service.service.upay.UPayType;
import cn.hutool.core.bean.BeanUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Date;

@Data
public class CMSUserInfoDto {


    private String userId;

    private int lv;

    private String clickNum;

    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss.SSS",
            timezone = "America/New_York"
    )
    private Date regTime;

    private String energy;

    private String aiCoin;

    private String nick;


    private String openId;

    private int channel;


    private int isLock;
    private String shareId;

    private String starNum;


    private String tonNum;

    private int innerType;

    private String adChannel;

    private String btcVal;

    private String country;


    private int inviteNum;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime lastOfflineTime;

    private String tonVal;


    private String tronAddress;
    private String tonAddress;
    private String bscAddress;
    private String usdVal;

    public static CMSUserInfoDto of(CMSUserinfoBO userInfoEntity, RaceCfgEntity raceCfgEntity, RaceCfgEntity btcCfg) {
        CMSUserInfoDto cmsUserInfoDto = new CMSUserInfoDto();
        BeanUtil.copyProperties(userInfoEntity, cmsUserInfoDto, true);
        cmsUserInfoDto.setAiCoin(MathUtil.getNumFormat(userInfoEntity.getAiCoin(), raceCfgEntity.getRate()));
        cmsUserInfoDto.setBtcVal(MathUtil.getNumFormat(userInfoEntity.getBtcVal(), btcCfg.getRate()));
        cmsUserInfoDto.setTonNum(MathUtil.getNumFormat(userInfoEntity.getTonNum(), Def.Ton));
        cmsUserInfoDto.setTonVal(MathUtil.getNumFormat(userInfoEntity.getTonVal(), LuckType.TonRate));
        cmsUserInfoDto.setUsdVal(MathUtil.getNumFormat(userInfoEntity.getUsdVal(), UPayType.U_Rate));
        return cmsUserInfoDto;
    }


}
